﻿<template>
  <a-modal
    title="编辑明细费用上传通知"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="操作员编号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入操作员编号 " v-decorator="['operatorId']" />
        </a-form-item>
        <a-form-item label="操作员姓名 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入操作员姓名 " v-decorator="['operatorName']" />
        </a-form-item>
        <a-form-item label="终端编号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入终端编号 " v-decorator="['termNo']" />
        </a-form-item>
        <a-form-item label="证件号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入证件号 " v-decorator="['certNo']" />
        </a-form-item>
        <a-form-item label="机构系统跟踪号机构系统跟踪号，和拉取待结算时候返回的 org_trace_no 对应 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构系统跟踪号机构系统跟踪号，和拉取待结算时候返回的 org_trace_no 对应 " v-decorator="['orgTraceNo']" />
        </a-form-item>
        <a-form-item label="单据流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入单据流水号 " v-decorator="['docTraceNo']" />
        </a-form-item>
        <a-form-item label="门诊/住院流水号(医保门诊挂号/入院办理返回的就诊 id)ORG_002A 接口所返回的 mdtrt_id " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入门诊/住院流水号(医保门诊挂号/入院办理返回的就诊 id)ORG_002A 接口所返回的 mdtrt_id " v-decorator="['mdtrtId']" />
        </a-form-item>
        <a-form-item label="机构编号(国标医院编码)机构的国家统一编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构编号(国标医院编码)机构的国家统一编码 " v-decorator="['orgCode']" />
        </a-form-item>
        <a-form-item label="医疗费总额ORG_002A 接口所返回的medfee_sumamt " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入医疗费总额ORG_002A 接口所返回的medfee_sumamt " v-decorator="['medfeeSumamt']" />
        </a-form-item>
        <a-form-item label="移动支付中心颁发的支付授权码移动支付中心颁发的支付授权码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入移动支付中心颁发的支付授权码移动支付中心颁发的支付授权码 " v-decorator="['payAuthNo']" />
        </a-form-item>
        <a-form-item label="人员编码ORG_002A 接口所返回的 psn_no " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入人员编码ORG_002A 接口所返回的 psn_no " v-decorator="['psnNo']" />
        </a-form-item>
        <a-form-item label="险种类型ORG_002A 接口所返回的 insu_type " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入险种类型ORG_002A 接口所返回的 insu_type " v-decorator="['insuType']" />
        </a-form-item>
        <a-form-item label="分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " v-decorator="['subOrgCode']" />
        </a-form-item>
        <a-form-item v-show="false"><a-input v-decorator="['iD']" /></a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    NitfOrg002bInputEdit
  } from '@/api/modular/main/NitfOrg002bInputManage'
  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      edit (record) {
        this.visible = true
        setTimeout(() => {
          this.form.setFieldsValue(
            {
              iD: record.iD,
              operatorId: record.operatorId,
              operatorName: record.operatorName,
              termNo: record.termNo,
              certNo: record.certNo,
              orgTraceNo: record.orgTraceNo,
              docTraceNo: record.docTraceNo,
              mdtrtId: record.mdtrtId,
              orgCode: record.orgCode,
              medfeeSumamt: record.medfeeSumamt,
              payAuthNo: record.payAuthNo,
              psnNo: record.psnNo,
              insuType: record.insuType,
              subOrgCode: record.subOrgCode
            }
          )
        }, 100)
      },
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            NitfOrg002bInputEdit(values).then((res) => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
